import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

/* Layout */
import Layout from "../views/layout/Layout";

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
 **/
export const constantRouterMap = [
  {
    path: "/deviceadmin",
    component: () => import("@/views/admin/deviceadmin"),
    hidden: true,
    // meta: { keepAlive: true }
  },
  {
    path: "/setdeviceadmin",
    component: () => import("@/views/admin/set"),
    hidden: true,
  },
  {
    path: "/acceptStore",
    component: () => import("@/views/login/acceptStore"),
    hidden: true,
  },
  {
    path: "/login",
    component: () => import("@/views/login/index"),
    hidden: true,
  },
  { path: "/404", component: () => import("@/views/404"), hidden: true },
  {
    path: "/store",
    component: () => import("@/views/home/store"),
    hidden: true,
  },
  {
    path: "/",
    component: Layout,
    redirect: "/home",
    children: [
      {
        path: "home",
        name: "home",
        component: () => import("@/views/home/index"),
        meta: { title: "首页", icon: "home" },
      },
    ],
  },
  {
    path: "/ums",
    component: Layout,
    redirect: "/ums/member",
    name: "ums",
    meta: { title: "会员", icon: "home" },
    children: [
      {
        path: "appletSetting",
        name: "appletSetting",
        component: () => import("@/views/ums/setting"),
        meta: { title: "登录支付设置", icon: "order-setting" },
      },
      {
        path: "member",
        name: "member",
        component: () => import("@/views/ums/member/index"),
        meta: { title: "会员列表", icon: "product-list" },
      },

      {
        path: "addMember",
        name: "addMember",
        component: () => import("@/views/ums/member/add"),
        meta: { title: "添加会员" },
        hidden: true,
      },
      {
        path: "updateMember",
        name: "updateMember",
        component: () => import("@/views/ums/member/update"),
        meta: { title: "编辑会员" },
        hidden: true,
      },
      {
        path: "memberLevel",
        name: "memberLevel",
        component: () => import("@/views/ums/memberLevel/index"),
        meta: { title: "会员等级列表", icon: "product-list" },
      },

      {
        path: "addMemberLevel",
        name: "addMemberLevel",
        component: () => import("@/views/ums/memberLevel/add"),
        meta: { title: "添加会员等级" },
        hidden: true,
      },
      {
        path: "updateMemberLevel",
        name: "updateMemberLevel",
        component: () => import("@/views/ums/memberLevel/update"),
        meta: { title: "编辑会员等级" },
        hidden: true,
      },
      {
        path: "school",
        name: "school",
        component: () => import("@/views/ums/school/index"),
        meta: { title: "学校列表", icon: "product-list" },
      },

      {
        path: "addSchool",
        name: "addSchool",
        component: () => import("@/views/ums/school/add"),
        meta: { title: "添加学校" },
        hidden: true,
      },
      {
        path: "updateSchool",
        name: "updateSchool",
        component: () => import("@/views/ums/school/update"),
        meta: { title: "编辑学校" },
        hidden: true,
      },
      {
        path: "memberBlanceLog",
        name: "memberBlanceLog",
        component: () => import("@/views/ums/memberBlanceLog/index"),
        meta: { title: "余额日志记录", icon: "product-list" },
      },
      {
        path: "membermeal",
        name: "membermeal",
        component: () => import("@/views/ums/membermeal/index"),
        meta: { title: "会员套餐" },
      },
      {
        path: "addMemberMeal",
        name: "addMemberMeal",
        component: () => import("@/views/ums/membermeal/add"),
        meta: { title: "添加会员套餐" },
        hidden: true,
      },
      {
        path: "updateMemberMeal",
        name: "updateMemberMeal",
        component: () => import("@/views/ums/membermeal/update"),
        meta: { title: "更新会员套餐" },
        hidden: true,
      },
      {
        path: "membermealcommission",
        name: "membermealcommission",
        component: () => import("@/views/ums/membermealcommission/index"),
        meta: { title: "会员套餐分佣管理" },
      },
      {
        path: "commissionwithdrawal",
        name: "commissionwithdrawal",
        component: () => import("@/views/ums/commissionwithdrawal/index"),
        meta: { title: "佣金提现" },
      },
      {
        path: "memberapply",
        name: "memberapply",
        component: () => import("@/views/ums/memberapply/index"),
        meta: { title: "配送员/推广员审核" },
      },
      {
        path: "membermealorder",
        name: "membermealorder",
        component: () => import("@/views/ums/membermealorder/index"),
        meta: { title: "VIP题库订单列表", icon: "product-list" },
      },
    ],
  },
  {
    path: "/yunying",
    component: Layout,
    redirect: "/sys/admin",
    name: "yunying",
    meta: { title: "运营管理", icon: "home" },
    children: [
      {
        path: "yunying",
        name: "yunying",
        component: () => import("@/views/qsg/yunying/edit"),
        meta: { title: "运营管理", icon: "product-list" },
      }]
  },
  {
    path: "/sys",
    component: Layout,
    redirect: "/sys/admin",
    name: "sys",
    meta: { title: "系统管理", icon: "home" },
    children: [
      {
        path: "admin",
        name: "admin",
        component: () => import("@/views/sys/admin/index"),
        meta: { title: "用户列表", icon: "product-list" },
      },
      {
        path: "gen",
        name: "gen",
        component: () => import("@/views/sys/gen/index"),
        meta: { title: "代码生成", icon: "product-list" },
      },
      {
        path: "permissionCategory",
        name: "permissionCategory",
        component: () => import("@/views/sys/permissionCategory/index"),
        meta: { title: "菜单类别列表}" },
      },
      {
        path: "addPermissionCategory",
        name: "addPermissionCategory",
        component: () => import("@/views/sys/permissionCategory/add"),
        meta: { title: "添加菜单类别", icon: "permissionCategory-add" },
        hidden: true,
      },
      {
        path: "updatePermissionCategory",
        name: "updatePermissionCategory",
        component: () => import("@/views/sys/permissionCategory/update"),
        meta: { title: "修改菜单类别", icon: "permissionCategory-update" },
        hidden: true,
      },
      {
        path: "addAdmin",
        name: "addAdmin",
        component: () => import("@/views/sys/admin/add"),
        meta: { title: "添加用户" },
        hidden: true,
      },
      {
        path: "updateAdmin",
        name: "updateAdmin",
        component: () => import("@/views/sys/admin/update"),
        meta: { title: "编辑用户" },
        hidden: true,
      },
      {
        path: "role",
        name: "role",
        component: () => import("@/views/sys/role/index"),
        meta: { title: "角色列表", icon: "product-list" },
      },
      {
        path: "addRole",
        name: "addRole",
        component: () => import("@/views/sys/role/add"),
        meta: { title: "添加角色" },
        hidden: true,
      },
      {
        path: "updateRole",
        name: "updateRole",
        component: () => import("@/views/sys/role/update"),
        meta: { title: "编辑角色" },
        hidden: true,
      },
      {
        path: "permission",
        name: "permission",
        component: () => import("@/views/sys/permission/index"),
        meta: { title: "权限列表", icon: "product-list" },
      },
      {
        path: "addPermission",
        name: "addPermission",
        component: () => import("@/views/sys/permission/add"),
        meta: { title: "添加权限" },
        hidden: true,
      },
      {
        path: "updatePermission",
        name: "updatePermission",
        component: () => import("@/views/sys/permission/update"),
        meta: { title: "编辑权限" },
        hidden: true,
      },
      {
        path: "area",
        name: "area",
        component: () => import("@/views/sys/area/index"),
        meta: { title: "权限列表", icon: "product-list" },
      },
      {
        path: "addArea",
        name: "addArea",
        component: () => import("@/views/sys/area/add"),
        meta: { title: "添加权限" },
        hidden: true,
      },
      {
        path: "updateArea",
        name: "updateArea",
        component: () => import("@/views/sys/area/update"),
        meta: { title: "编辑权限" },
        hidden: true,
      },
      {
        path: "webLog",
        name: "webLog",
        component: () => import("@/views/sys/webLog/index"),
        meta: { title: "前台日志列表", icon: "product-list" },
      },
      {
        path: "adminLog",
        name: "adminLog",
        component: () => import("@/views/sys/adminLog/index"),
        meta: { title: "后台日志列表", icon: "product-list" },
      },
      {
        path: "adminLogStatic",
        name: "adminLogStatic",
        component: () => import("@/views/sys/adminLog/adminLogStatic"),
        meta: { title: "后台日志列表", icon: "product-list" },
      },
      {
        path: "webLogStatic",
        name: "webLogStatic",
        component: () => import("@/views/sys/webLog/webLogStatic"),
        meta: { title: "后台日志列表", icon: "product-list" },
      },
      {
        path: "dict",
        name: "dict",
        component: () => import("@/views/sys/dict/index"),
        meta: {
          title: "系统配置信息表列表}",
        },
      },
      {
        path: "addDict",
        name: "addDict",
        component: () => import("@/views/sys/dict/add"),
        meta: {
          title: "添加系统配置信息表",
          icon: "dict-add",
        },
      },
      {
        path: "updateDict",
        name: "updateDict",
        component: () => import("@/views/sys/dict/update"),
        meta: {
          title: "修改系统配置信息表",
          icon: "dict-update",
        },
        hidden: true,
      },
      {
        path: "store",
        name: "store",
        component: () => import("@/views/sys/store/index"),
        meta: {
          title: "店铺列表",
        },
      },
      {
        path: "updateStore",
        name: "updateStore",
        component: () => import("@/views/sys/store/update"),
        meta: {
          title: "更新店铺",
        },
      },
      {
        path: "storesetting",
        name: "storesetting",
        component: () => import("@/views/sys/store/setting"),
        meta: {
          title: "店铺设置",
        },
      },
    ],
  },
  {
    path: "/dms",
    component: Layout,
    redirect: "/dms/order",
    name: "dms",
    meta: { title: "订单", icon: "order" },
    children: [
      {
        path: "order",
        name: "order",
        component: () => import("@/views/dms/order/index"),
        meta: { title: "订单列表", icon: "product-list" },
      },
      {
        path: "rechargeOrder",
        name: "rechargeOrder",
        component: () => import("@/views/qsg/rechargeOrder/index"),
        meta: { title: "充值订单", icon: "product-list" },
      }
    ],
  },
  {
    path: "/drivermanage",
    component: Layout,
    redirect: "/drivermanage/banner",
    name: "drivermanage",
    meta: { title: "设备管理", icon: "product-list" },
    children: [
      {
        path: "device",
        name: "device",
        component: () => import("@/views/qsg/device/index"),
        meta: { title: "设备管理", icon: "product-list" },
      },
      {
        path: "addDevice",
        name: "addDevice",
        component: () => import("@/views/qsg/device/add"),
        meta: { title: "添加设备" },
        hidden: true,
      },
      {
        path: "updateDevice",
        name: "updateDevice",
        component: () => import("@/views/qsg/device/update"),
        meta: { title: "编辑设备" },
        hidden: true,
      },
      {
        path: "banner",
        name: "banner",
        component: () => import("@/views/dms/banner/index"),
        meta: { title: "首页轮播", icon: "product-list" },
      },
      {
        path: "addBanner",
        name: "addBanner",
        component: () => import("@/views/dms/banner/add"),
        meta: { title: "添加图片" },
        hidden: true,
      },
      {
        path: "updateBanner",
        name: "updateBanner",
        component: () => import("@/views/dms/banner/update"),
        meta: { title: "编辑图片" },
        hidden: true,
      },
      {
        path: "room",
        name: "room",
        component: () => import("@/views/qsg/room/index"),
        meta: { title: "房间管理", icon: "product-list" },
      },
      {
        path: "updateRoom",
        name: "updateRoom",
        component: () => import("@/views/qsg/room/update"),
        meta: { title: "房间管理", icon: "product-list" },
      },
      {
        path: "addRoom",
        name: "addRoom",
        component: () => import("@/views/qsg/room/add"),
        meta: { title: "房间管理", icon: "product-list" },
      },
      {
        path: "devicemeal",
        name: "devicemeal",
        component: () => import("@/views/qsg/devicemeal/index"),
        meta: { title: "支付套餐" },
      },
      {
        path: "addDevicemeal",
        name: "addDevicemeal",
        component: () => import("@/views/qsg/devicemeal/add"),
        meta: { title: "添加套餐" },
      },
      {
        path: "meituan",
        name: "meituan",
        component: () => import("@/views/qsg/devicemeal/meituanindex"),
        meta: { title: "添加套餐" },
      },
      {
        path: "updateDevicemeal",
        name: "updateDevicemeal",
        component: () => import("@/views/qsg/devicemeal/update"),
        meta: { title: "编辑套餐" },
        hidden: true,
      },
      {
        path: "recharge",
        name: "recharge",
        component: () => import("@/views/qsg/recharge/index"),
        meta: { title: "充值套餐" },
        hidden: true,
      },
      {
        path: "hexiao",
        name: "hexiao",
        component: () => import("@/views/qsg/hexiao/index"),
        meta: { title: "核销管理" },
        hidden: true,
      },
      {
        path: "addRecharge",
        name: "addRecharge",
        component: () => import("@/views/qsg/recharge/add"),
        meta: { title: "添加充值套餐" },
      },
      {
        path: "updateRecharge",
        name: "updateRecharge",
        component: () => import("@/views/qsg/recharge/update"),
        meta: { title: "编辑充值套餐" },
      },
      {
        path: "certificate",
        name: "certificate",
        component: () => import("@/views/qsg/certificate/index"),
        meta: { title: "团购券管理" },
        hidden: true,
      },
      {
        path: "updateDynamic",
        name: "updateDynamic",
        component: () => import("@/views/dms/dynamic/update"),
        meta: { title: "编辑动态" },
      },
      {
        path: "webnet",
        name: "webnet",
        component: () => import("@/views/dms/webnet/index"),
        meta: { title: "官网配置" },
      },
    ],
  },
  {
    path: "/gateway",
    component: Layout,
    redirect: "/drivermanage/banner",
    name: "gateway",
    meta: { title: "网关配置", icon: "product-list" },
    children: [
      {
        path: "gatewayinfo",
        name: "gatewayinfo",
        component: () => import("@/views/qsg/gateway/index"),
        meta: { title: "网关信息", icon: "product-list" },
      },
      {
        path: "addGatewayinfo",
        name: "addGatewayinfo",
        component: () => import("@/views/qsg/gateway/add"),
        meta: { title: "添加网关" },
        hidden: true,
      },
      {
        path: "updateGatewayinfo",
        name: "updateGatewayinfo",
        component: () => import("@/views/qsg/gateway/update"),
        meta: { title: "编辑网关" },
        hidden: true,
      },
      {
        path: "gatewaydevice",
        name: "gatewaydevice",
        component: () => import("@/views/qsg/gatewaydevice/index"),
        meta: { title: "网关设备" },
        hidden: true,
      },
      {
        path: "adddevice",
        name: "adddevice",
        component: () => import("@/views/qsg/gatewaydevice/add"),
        meta: { title: "添加设备" },
        hidden: true,
      },
      {
        path: "updatedevice",
        name: "updatedevice",
        component: () => import("@/views/qsg/gatewaydevice/update"),
        meta: { title: "编辑设备" },
        hidden: true,
      },
    ],
  },

  { path: "*", redirect: "/404", hidden: true },
];

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior (to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { x: 0, y: 0 }
    }
  },
  routes: constantRouterMap,
});
